/**
 * @brief    平面 9 节点四边形形函数
 * 
 * @author   Liu Xing
 * @date     2025.10.24
 * @par Copyright(c):  ShenGong  Simulation corporation
 */

#pragma once
#define NDEBUG
#include <assert.h>
#include <vector>
#include "Utility/Algebra/Matrix.h"
#include "DataStructure/Common/SGNamespace.h"
#include "DataStructure/Input/Solver/IntegPoint.h"
#include "SGFem/Integration/Common/IntegrationExport.h"

SG_NAMESPACE_OPEN
namespace FEMSolver {
namespace Element {

/** @brief 9 节点四边形形函数
 * 
 * 采用 `Lagrange`格式。
 * 传入积分格式，返回积分点处形函数及形函数对参数坐标导数
 */
class Integration_DECLSPEC Quad9NodeShpFunc
{
public:
    Quad9NodeShpFunc ();
    void Compute (const SG::DataStructure::FEM::IntegPointArray& integPoints);
    const SG::Algebra::Matrixd& GetShapeFunction (int index) const;
    const SG::Algebra::Matrixd& GetShapeFunctionDerivative (int index) const;

private:
    std::vector<SG::Algebra::Matrixd> NSet;
    std::vector<SG::Algebra::Matrixd> DNDxiSet;
};

inline const SG::Algebra::Matrixd& Quad9NodeShpFunc::GetShapeFunction (int index) const
{
    assert (index < NSet.size ());
    return NSet[index];
}

inline const SG::Algebra::Matrixd& Quad9NodeShpFunc::GetShapeFunctionDerivative (int index) const
{
    assert (index < DNDxiSet.size ());
    return DNDxiSet[index];
}

}; // end namaspace FEMSolver
}; // end namespace Element
SG_NAMESPACE_CLOSE